#%RAML 0.8
---
title: SLL Service Catalogue Capacity Service
version: 1.0
baseUri: http://localhost:8080/capacity
documentation:
  - title: General API information
    content: TODO! Description of the Capacity Service Functions
protocols: [HTTP,HTTPS]

schemas:
    - careUnitReference: !include schema/careUnitReference.json
    - careUnit: !include schema/careUnit.json
    - careUnitRefList: !include schema/careUnitRefList.json
    - productReference: !include schema/productReference.json
    - productRefList: !include schema/productRefList.json
    - capacity: !include schema/capacity.json
    - capacityList: !include schema/capacityList.json
    - unit: !include schema/unit.json
    - unitList: !include schema/unitList.json
    - unitIds: !include schema/unitIds.json
    - serviceException: !include schema/serviceException.json

/capacity:
  description: Service for creating, updating, reading capacities.
  displayName: CapacityService
  get:
    description: Get all stored capacities, grouped by Care Units and Products
    responses:
      500:
        description: Unknown exception in the service
        body:
          application/json:
            schema: serviceException
            example: |
              {
                "code" : "INVALID_DAYS_FROM_NOW_RANGE",
                "data" :
                  {
                    "14"
                  }
              }
      200:
        description: The requested capacity information was found and is returned in the body.
        body:
          application/json:
            schema: careUnitRefList
            example : |
              {
                "hsaID": "SE2321000016-3TNL",
                "product": [
                    {
                        "capacity": [
                            {
                                "code": "2",
                                "codeSystem": "oid.sll.vantetider",
                                "createdByHsaID": "CREATED",
                                "creationTime": 1425410281000,
                                "product": null,
                                "sourceSystemHsaID": "SOURCE",
                                "validTo": 1427410800000,
                                "value": "4"
                            },
                            {
                                "code": "1",
                                "codeSystem": "oid.sll.vantetider",
                                "createdByHsaID": "CREATED",
                                "creationTime": 1425410242000,
                                "product": null,
                                "sourceSystemHsaID": "SOURCE",
                                "validTo": 1427410800000,
                                "value": "16"
                            }
                        ],
                        "hsaID": "SE2321000016-1HF3",
                        "name": "40"
                    }
                ]
  post:
    description: Create a new capacity
    body:
      application/json: 
        schema: careUnit
        example : |
          {
            "hsaID" : "SE2321000016-1HF3",
            "product" : "???",
            "code" : "1",
            "codeSystem" : "oid.sll.vantetider",
            "value" : "18",
            "validTo" : "1427410800000"
          }
    responses:
      201:
        description: Creation successful.
  put:
    description: Update a capacity
    body:
      application/json: 
        schema: careUnit
        example : |
          {
            "hsaID" : "SE2321000016-1HF3",
            "product" : "???",
            "code" : "1",
            "codeSystem" : "oid.sll.vantetider",
            "value" : "18",
            "validTo" : "1427410800000"
          }
    responses:
      200:
        description: Update successful.
  /{hsaId}:
    description: Service for managing the capacity information for a specific care unit HSA-id.
    uriParameters:
       hsaId:
         displayName: The Hsa-id for the care unit to list capacity information for
         type: string
    get:
      description: Reads all capacities belonging to a specific Care Unit       
      responses:
        200:
          description: The requested capacity information was found and is returned in the body.
          body:
            application/json:
              schema: careUnitRefList
              example : |
                {
                  "hsaID": "SE2321000016-3TNL",
                  "product": [
                      {
                          "capacity": [
                              {
                                  "code": "2",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410281000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "4"
                              },
                              {
                                  "code": "1",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410242000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "16"
                              }
                          ],
                          "hsaID": "SE2321000016-1HF3",
                          "name": "40"
                      }
                  ]
  /byunitids:
    description: List all capacities for an incoming list of Care Units HSA-id:s
    post:
      body:
        application/json:
          schema: unitList
          example: |
            {
                "units": [
                    {
                        "unitId": "SE2321000016-14VK"
                    },
                    {
                        "unitId": "SE2321000016-3M0N"
                    }
                ]
            }
      responses:
        200:
          description: The requested capacity information was found and is returned in the body.
          body:
            application/json:
              schema: careUnitRefList
              example : |
                {
                  "hsaID": "SE2321000016-3TNL",
                  "product": [
                      {
                          "capacity": [
                              {
                                  "code": "2",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410281000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "4"
                              },
                              {
                                  "code": "1",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410242000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "16"
                              }
                          ],
                          "hsaID": "SE2321000016-1HF3",
                          "name": "40"
                      }
                  ]
  /{hsaId}/{product}/{code}:
    description: Service for handling a specific combination of Hsa-id, Product and Code.
    uriParameters:
      hsaId:
        displayName: The care unit Hsa Id to filter for
        type: string
      product:
        displayName: The product code to filter fort
        type: string
      code:
        displayName: The code system code to filter for
        type: string
    delete: 
      description: Delete capacities for a specific combination of unitId, product and code.
      responses:
        200:
          description: Deletion successful.
  /findexpiring/{withinDaysFromNow}:
    description: Find all of of the care unit HSA id:s that have capacities that are expiring within the provided timeframe
    uriParameters:
      withinDaysFromNow:
        displayName: Within days from now
        type: integer
    get:
      description: Find all of of the care unit HSA id:s that have capacities that are expiring within the provided timeframe
      responses:
       200:
         body:
          application/json:
            schema: unitIds
            example: |
              {
                  "values": [
                    "SE2321000016-1HF3",
                    "SE2321000016-6Fw9"
                  ],
                  "empty":false
              }